package com.hippy.erya.config.interceptor;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;

/**
 */
@Configuration
public class FiltersConfig {


    @Bean
    public FilterRegistrationBean crossOriginFilter() {
        FilterRegistrationBean filterReg = new FilterRegistrationBean();
        filterReg.setFilter(new CrossOriginFilter());
        // 优先级
        filterReg.setOrder(-3);
        filterReg.setDispatcherTypes(DispatcherType.REQUEST);
        // 匹配过滤路径
        filterReg.addUrlPatterns("/*");

        return filterReg;
    }
}
